<!--
 * @Author: Hzt
 * @Date: 2024-01-11 17:48:43
 * @LastEditTime: 2025-02-18 11:36:28
 * @LastEditors: Hzt
 * @Description: ***
 * @FilePath: \cty_admin\src\views\withdrawal\withdrawalList\index.vue
-->
<template>
  <div class="main-page">
    <PageSearch :search-form-config="searchFormConfig" :form-data.sync="formData" @searchBtnClick="handleSearch" />
    <PageContent ref="pageContent" :form-data="formData" :content-table-config="contentConfig">
      <template #operate="{ row }">
        <el-button type="text" size="small" icon="el-icon-view" @click="handleView(row)">
          查看详情
        </el-button>
        <el-button type="text" size="small" icon="el-icon-lock" @click="handlePermission(row)">
          权限
        </el-button>
      </template>
    </PageContent>

    <!-- 收益明细 -->
    <user-detail v-if="showDetail" :show.sync="showDetail" :init-params="initParams" />

    <permission v-if="showPermission" :show.sync="showPermission" :init-params1="initParams1" @confirm="handleAuth" />
  </div>
</template>

<script>
import { contentConfig } from "./config/content.config";
import { searchFormConfig } from "./config/search.config";
import { modalFormConfig } from "./config/modal.config";
import userDetail from "./userDetail.vue";
import permission from "./permission.vue";
import { getAuthority,purseAuthority } from "@/api/withdrawal";

export default {
  name: "WithdrawalList",
  components: { userDetail, permission },
  data() {
    return {
      showDetail: false,
      showPermission: false,
      purseId: "",
      contentConfig,
      searchFormConfig,
      modalFormConfig,
      formData: {}, // 搜索表单数据
    };
  },
  mounted() {

  },
  methods: {
    getAuthorityReq(id) {
      getAuthority(id).then(res => {
        this.initParams1 = {
          ...res.data,
          cb: () => {
            this.showPermission = false;
          },
        };
        this.showPermission = true
      }).catch(err => {
        console.log(err)
      })
    },
    handleSearch() {
      this.$refs.pageContent.queryTblMain();
    },
    handlePermission({ userId }) {
      this.getAuthorityReq(userId)
    },
    handleAuth(data){
      purseAuthority(data).then(res=>{
        console.log(res)
        if(res.code === 200) {
          this.$message.success('修改成功')
          this.showPermission = false;
        }
      }).catch(err=>{
        console.log(err)
      })
    },
    handleView({ id }) {
      this.initParams = {
        purseId: id,
        cb: () => {
          this.showDetail = false;
        },
      };
      this.showDetail = true;
    },
  },
};
</script>
<style lang="scss" scoped>
.main-page-content {
  height: 100%;
}
</style>
